      SUBROUTINE BOTDEPS(HW,DEPB,CGWNSB,CWNSB,NPB,LHB,MX)
C
C     THIS SUBROUTINE REDEFINES THE DEPTHS AND INTERCEPTS OF
C     THE WAVE NUMBER SQUARED IN THE BOTTOM. THE DEPTHS
C     MOVE UP AND DOWN AS THE WATER DEPTH HW CHANGES WHILE THE 
C     INTERCEPTS MOVE WITH THEM. THE SUBROUTINE THE FINDS THE 
C     INDEX LHB OF THE LAYER IN THE NEW DEPTH PRROFILE THAT 
C     CONTAINS HB. THE SQUARED INDEX OF REFRACTION CAN BE 
C     INTERPOLATED OR EXTRAPOLATED TO HB BASED ON LHB.
C
      IMPLICIT REAL*8 (A-H,O-Z)
      COMPLEX*16 CGWNSB(MX),CWNSB(MX) 
      DIMENSION DEPB(MX)
C
      COMMON /BLKEVN/ HB,CW,CB,FKW,FKB,ROHW,ROHB,ATEN
C
C     DEPB(1) IS ASSUMED TO BE THE WATER DEPTH BEFORE THE DEPTH
C     CHANGES TO HW. MOVE THE DEPTHS AND INTERCEPTS.
C
      DELH=HW-DEPB(1)
      DO 50 I=1,NPB
      DEPB(I)=DEPB(I)+DELH
      CWNSB(I)=CWNSB(I)-CGWNSB(I)*DCMPLX(DELH,0.0D0)
   50 CONTINUE
C
      IF(HB .LE. DEPB(1)) THEN
      WRITE(6,*) 'NO BOTTOM PROFILE WATER DEPTH= ',HW
      WRITE(6,*) 'AND BOTTOM DEPTH= ',HB
      WRITE(6,*) '*** MAKE HB BIGGER ***'
      WRITE(9,*) 'NO BOTTOM PROFILE WATER DEPTH= ',HW
      WRITE(9,*) 'AND BOTTOM DEPTH= ',HB
      WRITE(9,*) '*** MAKE HB BIGGER ***'
      STOP 'MAKE HB BIGGER'
      END IF 
C
      LHB=0
      NPBM1=NPB-1
      DO 100 I=1,NPBM1
      IF(DEPB(I+1) .GE. HB) GO TO 200
  100 CONTINUE
C
C     HB IS .GT. DEPB(NP)
C
      LHB=NPB
      GO TO 250
C
  200 CONTINUE
      LHB=I
  250 CONTINUE
C
      RETURN
      END
